/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import entities.Product;
import java.sql.Connection;
import java.sql.PreparedStatement;
import entities.ShoppingCart;
import entities.Transactions;
import factory.DBConnectionFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author theworldiwant
 */
public abstract class MYSQLTransactionsDAO extends TransactionsDAO{
    @Override
    public void checkOut(ShoppingCart crt){
        try{
            DBConnectionFactory myFactory = DBConnectionFactory.getInstance(DAOFactory.MYSQL);
            Connection conn = myFactory.getConnection();
            PreparedStatement pstmt = conn.prepareStatement("");
            pstmt.executeUpdate();
            conn.close();
        }catch(SQLException ex){
            Logger.getLogger(MYSQLTransactionsDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
    
    }
    public List<Transactions> viewRecentTransaction(){
        try {
            // TODO code application logic here
            DBConnectionFactory myFactory = DBConnectionFactory.getInstance(DAOFactory.MYSQL);
            Connection conn = myFactory.getConnection();
            PreparedStatement pstmt = conn.prepareStatement("select * from transactions where name dateIn bet");
            ResultSet rs = pstmt.executeQuery();
            List<Transactions> result = new ArrayList<Transactions>();
            Transactions oneTransaction;
            while (rs.next()){
                
                oneTransaction = new Transactions(); 
                oneTransaction.getId();
                oneTransaction.getUserId();
                oneTransaction.getCartId();
                oneTransaction.getTotal();
                oneTransaction.getAmount();
                oneTransaction.getDate();
                oneTransaction.getTime();
                oneTransaction.getShippingAddress();
                oneTransaction.getPaymentOptions();
                result.add(oneTransaction);
            }
            conn.close();
            return result;
        } catch (SQLException ex) {
            Logger.getLogger(MYSQLTransactionsDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    
    }
}
